package com.yvnze.ydyp.common.exception;

import com.yvnze.ydyp.common.enums.ErrorCodeEnum;

/**
 * @author HaiPeng Wang
 * @date 2021/8/13 16:49
 * @Description:系统内部异常类，用于内部逻辑处理,必须通过ErrorCodeEnum创建
 */
public class SysException extends RuntimeException{
    private Integer code;

    public SysException(Integer code, String msg){
        super(msg);
        this.code = code;
    }

    public SysException(ErrorCodeEnum errorCodeEnum){
        super((String) errorCodeEnum.getMsg());
        this.code = errorCodeEnum.getCode();
    }

    public SysException(RuntimeException e){
        super(e.getMessage());
        this.code = -1;
    }

    public Integer getCode() {
        return code;
    }
}
